import { ListItem } from '../home/homeReducer'
export const ADD_CAR_ITEM = 'ADD_CAR_ITEM';
export const ADD_CAR_ITEM_COUNT = 'ADD_CAR_ITEM_COUNT'
export const DELETE_CAR_ITEMS = 'DELETE_CAR_ITEMS'
export const SWITCH_CAR_ITEM = 'SWITCH_CAR_ITEM'
export const SUB_CAR_ITEM_COUNT = 'SUB_CAR_ITEM_COUNT'
export const MODIFY_ALL_CAR_ITEM_ISChECKED = 'MODIFY_ALL_CAR_ITEM_ISChECKED'
export const ADD_CAR_ITEM_CUSTOM_COUNT = 'ADD_CAR_ITEM_CUSTOM_COUNT'

export interface AddCarState {
	type: typeof ADD_CAR_ITEM
	payload: ListItem
}

export function addCarAction(payload: ListItem): AddCarState{
	return { type: ADD_CAR_ITEM, payload }
}

export interface ADDCarItemCountState {
	type: typeof ADD_CAR_ITEM_COUNT
	payload: string
}

export function addCarItemCountAction(payload: string): ADDCarItemCountState {
	return { type: ADD_CAR_ITEM_COUNT, payload }
}


export interface SubCarItemCountState {
	type: typeof SUB_CAR_ITEM_COUNT
	payload: string
}

export function subCarItemCountAction(payload: string): SubCarItemCountState {
	return { type: SUB_CAR_ITEM_COUNT, payload }
}

export interface SwitchCarItemState {
	type: typeof SWITCH_CAR_ITEM
	payload: string
}

export function switchCarItemAction(payload: string): SwitchCarItemState {
	return { type: SWITCH_CAR_ITEM, payload }
}

export interface ModifyAllCarItemCheck {
	type: typeof MODIFY_ALL_CAR_ITEM_ISChECKED
	payload: boolean
}

export function modifyAllCarItemCheckAction(payload: boolean): ModifyAllCarItemCheck {
	return { type: MODIFY_ALL_CAR_ITEM_ISChECKED, payload }
}

export interface DeleteCarItems {

	type: typeof  DELETE_CAR_ITEMS
}

export function deleteCarItemsAction(): DeleteCarItems {
	return { type:  DELETE_CAR_ITEMS}
}

export interface AddCarItemCustomCount {
	type: typeof ADD_CAR_ITEM_CUSTOM_COUNT
	payload: {
		item: ListItem
		count: number
	}
}

export function addCarItemCustomCountAction(payload: {
	item: ListItem
	count: number
}): AddCarItemCustomCount {
	return { type: ADD_CAR_ITEM_CUSTOM_COUNT, payload }
}

export type CarAction = AddCarState | ADDCarItemCountState | SubCarItemCountState | SwitchCarItemState | ModifyAllCarItemCheck | DeleteCarItems | AddCarItemCustomCount